<template>
	<view>
		<view class="lb-main-32">
			<view class="lb-box">
				<view class="lb-item">
					<view class="price">
						{{data.cash || "0.00"}}
					</view>
					<view class="label">
						已提现
					</view>
				</view>
				<view class="lb-item">
					<view class="price">
						{{data.wait_cash || "0.00" }}
					</view>
					<view class="label">
						待提现
					</view>
				</view>
			</view>

			<view class="lb-list" v-for="(item,index) in listData" :key="index">
				<view class="lb-item">
					<view class="item-top">
						<view class="lb-left">
							<image :src="getImgUrl(item.cover_image)" mode="aspectFit"></image>
						</view>
						<view class="lb-right">
							<view class="lb-name">
								{{item.goods_name}} </text>
							</view>
							<view class="lb-time">
								{{item.createtime}}
							</view>
						</view>
					</view>
					<view class="item-foot">
						<view class="foot-box">
							用户名：{{item.user.name}}
						</view>
						<view class="foot-box">
							订单号：{{item.order_num}}
						</view>
						<view class="foot-box">
							收益：￥{{item.royalty}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		channelRoyalty
	} from "@/api/apis/retail.js"
	import {
		setImgUrl
	} from "@/utils/comm.js"
	export default {
		data() {
			return {
				data: '',
				page: 1,
				limit: 10,
				listData: [],
				isLoading: false
			}
		},
		methods: {
			getImgUrl(url) {
				return setImgUrl(url);
			},
			getData() {
				uni.showLoading({
					title: '请求中',
					mask: true
				});
				this.isLoading = true;
				channelRoyalty({
					page: this.page,
					limit: this.limit,
				}).then(res => {
					uni.hideLoading();
					if (res.code == 1) {
						this.data = res.data;
						this.listData = res.data.log
					}

				})
			}
		},
		onReachBottom() {
			//注意 这里是重要的一步，不满足条件下拉加载不能继续请求数据
			if (!this.isLoading) {
				// this.getData();
			}
		},
		onShow() {
			this.getData();
		}
	}
</script>

<style lang="scss">
	//列表
	.lb-list {
		display: flex;
		background: rgba(255, 255, 255, 1);
		padding: 24rpx 0;
		border-radius: 16rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;


		.lb-item {
			width: 100%;
			display: flex;
			flex-direction: column;


			.item-top {
				display: flex;
				padding: 0 32rpx 24rpx;

				.lb-left {
					image{
						width: 100rpx;
						height: 100rpx;
						background-color: #eee;
						border-radius: 10rpx;
					}
				}

				.lb-right {
					display: flex;
					flex-direction: column;
					width: calc(100% - 80rpx);
					justify-content: space-between;
					padding-left: 24rpx;

					.lb-name {
						font-size: $main-font-28;
						color: $main-font-color;


						text {
							font-size: $main-font-24;
							color: $main-font-color-grey6;
							padding-left: 24rpx;
						}
					}

					.lb-time {
						font-size: $main-font-28;
						color: $main-font-color-grey9;
					}
				}

			}

			.item-foot {
				padding: 0 32rpx;

				.foot-box {
					margin-bottom: 10rpx;
					display: flex;
					align-items: center;
					font-size: $main-font-28;
					color: $main-font-color;
				}
			}
		}

	}

	.lb-box {
		display: flex;
		justify-content: space-around;
		margin-bottom: 30rpx;

		// padding: 20rpx 0;
		.lb-item {
			width: 300rpx;
			background: linear-gradient(to bottom right, #B6E8FD, #4F99F5);
			height: 218rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			border-radius: 16rpx;

			&:nth-of-type(3n-1) {
				background: linear-gradient(to bottom right, #FEE4B6, #FE835D);

			}

			&:nth-of-type(4n-1) {
				background: linear-gradient(to bottom right, #FEDDD6, #FD6344);

			}

			.price {
				font-size: $main-font-32;
				color: $main-font-color-white;

				&::before {
					content: '¥ ';
					font-size: $main-font-20;
				}
			}

			.price2 {
				font-size: $main-font-32;
				color: $main-font-color-white;
			}

			.label {
				font-size: $main-font-28;
				color: $main-font-color-white;
				padding-top: 18rpx;
			}
		}

	}
</style>